﻿namespace MiP.Xml.Core.StringEvaluation
{
    internal class FoundDollarEvaluationState : EvaluationState
    {
        internal override EvaluationState Next(EvaluationContext context)
        {
            char currentChar = context.ReadNextChar();
            if (currentChar == '$')
            {
                context.Result.Append("$");
                context.Incomplete.Clear();
                return new ReadToDollarEvaluationState();
            }

            if (currentChar != '{')
            {
                context.Result.Append("$");
                context.Incomplete.Clear();
                context.Result.Append(currentChar);
                return new ReadToDollarEvaluationState();
            }

            context.Incomplete.Append("{");
            context.VariableName.Clear();
            return new ReadVariableNameEvaluationstate();
        }
    }
}